#include <iostream>
#include <vector>
using namespace std;
void ShellSort(vector<int>& vc, int n)
{
	int gap = n;
	while (gap > 1)
	{
		gap = gap / 2;
		for (int i = 0; i < n - gap; i++)
		{
			int key = vc[i + gap];
			int j = i;
			while (j >= 0 && vc[j] > key)
			{
				vc[gap + j] = vc[j];
				j -= gap;
			}
			vc[j + gap] = key;
		}
	}
}
int main()
{
	vector<int> vc = { 1,5,4,3,9,5,7,8,2 };
	ShellSort(vc, vc.size());
	for (auto e : vc)
	{
		cout << e << " ";
	}


	return 0;
}
